package com.canyou.captcha;

import com.canyou.util.CryptUtil;
import com.jfinal.kit.StringKit;

public abstract class CaptchaService {

	public static String encode(String randomCode) {
		return CryptUtil.encrypt(randomCode);
	}

	public static boolean validate(String inputRandomCode,
			String rightRandomCode) {
		if (StringKit.isBlank(inputRandomCode))
			return false;
		try {
			inputRandomCode = encode(inputRandomCode);
			return inputRandomCode.equals(rightRandomCode);
		} catch (Exception e) {
			return false;
		}
	}
}